/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rh.game.impl;

import com.rh.game.Character;
import com.rh.game.GameClothing;
import com.rh.game.GameCondition;
import com.rh.game.GameMoney;
import com.rh.game.GameObject;

/**
 *
 * @author Hayden
 */
public class GameCondition1 implements GameCondition {
    public static enum Type  {
        GENDER_CHECK_FEMALE, GENDER_CHECK_MALE, HAS_MONEY, WEARING_BODY_CLOTHING, WEARING_HAND;
    }
    
    public static final GameCondition1 isFemale(Character pWhom)  {
        return new GameCondition1(Type.GENDER_CHECK_FEMALE, pWhom);
    }
    public static final GameCondition1 isMale(Character pWhom)  {
        return new GameCondition1(Type.GENDER_CHECK_MALE, pWhom);
    }
    public static final GameCondition1 hasMoney(Character pWhom)  {
        return new GameCondition1(Type.HAS_MONEY, pWhom);
    }
    public static final GameCondition1 isWearingClothing(Character pWhom)  {
        return new GameCondition1(Type.WEARING_BODY_CLOTHING, pWhom);
    }
    public static final GameCondition1 isWearingHand(Character pWhom)  {
        return new GameCondition1(Type.WEARING_HAND, pWhom);
    }
    
    private Type type = null;
    private Type getType()  {
        return type;
    }
    
    private Character character = null;
    private Character getCharacter()  {
        return character;
    }
    
    public GameCondition1(Type pType, Character pWhom)  {
        super();
        type = pType;
        character = pWhom;
    }

    public boolean evaluate(Character whom)  {
        boolean e = false;
        if (type == Type.GENDER_CHECK_FEMALE)  {
            e = (whom.getGender() == Character.Gender.FEMALE);
        }
        else if (type == Type.GENDER_CHECK_MALE)  {
            e = (whom.getGender() == Character.Gender.MALE);
        }
        else if (type == Type.HAS_MONEY)  {
            for (GameObject go : whom.getInventory()) {
                if (go instanceof GameMoney)  return true;
            }
        }
        else if (type == Type.WEARING_BODY_CLOTHING)  {
            for (GameClothing gc : whom.getWearing()) {
                if (gc.getBodyPart() == Character.BodyPart.BODY)  return true;
            }
        }
        else if (type == Type.WEARING_HAND)  {
            for (GameClothing gc : whom.getWearing()) {
                if (gc.getBodyPart() == Character.BodyPart.HAND)  return true;
            }
        }
        
        return e;
    }
    
    public boolean evaluate()  {
        return evaluate(character);
    }
}
